package com.zzti.contril;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.zzti.Dao.EmployeeDao;
import com.zzti.Thired.Employee;
import com.zzti.impl.EmployeeDaoimpl;

/**
 * Servlet implementation class AddServlet
 */
public class AddServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;

   
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String name=request.getParameter("name");
		String sex=request.getParameter("sex");
		int age=Integer.parseInt(request.getParameter("age"));
		String dapartment=request.getParameter("dapartment");
		String type=request.getParameter("type");
		int year=Integer.parseInt(request.getParameter("year"));


		Employee em=new Employee();
		em.setName(name);
		em.setAge(age);
		em.setSex(sex);
		em.setDapartment(dapartment);
		em.setType(type);
		em.setYear(year);
		EmployeeDao ed=new EmployeeDaoimpl();
	      if(ed.AddEmployee(em)>0) {
	    	  response.sendRedirect("EmployeeServlet");
	      }
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request, response);
	}

}